<script type="text/javascript" src="<?php echo base_url();?>assets/ckeditor/ckeditor.js"></script>
<script>
	function setanswer(){
		var b = 0;
		a = document.testquestion.TextAntwort.value;
		$.get('<?php echo base_url()?>/index.php/klausurenfragen_controller/saveanswer/' + b + '/' + b  + '/' + b + '/' + a, function(data){ 
		});
	}
</script>

<?php $this->load->helper('form'); ?>
<?php echo validation_errors(); ?>
<?php echo form_open('klausurenfragen_controller/classtest_view/'.$page,array('name' => 'testquestion')) ?>

<input type="input" name="fragenid" hidden="true" value=<?php echo $fragen['ID'];?> />
<h1>Frage &nbsp;<?php echo $page ?>:</h1>
<p><?php echo $fragen['Frage'];?></p>

<!---------------------Antwort Textbox------------------------------>
<h2>Antwort:</h2>
<textarea type="input" name="TextAntwort" id="TextAntwort" rows="5" cols="20" /><?php if(isset($ergebnisse['TextAntwort'])) echo $ergebnisse['TextAntwort'];?></textarea> <br /></td>
<script>
//<![CDATA[
	CKEDITOR.replace( 'TextAntwort',
    {
		language : 'de',
		toolbar : 'Basic',
		toolbarCanCollapse : false,
		resize_enabled : false,
		removePlugins : 'elementspath',
		toolbar_Basic :
		[
			{ name: 'clipboard', items : [ 'PasteText','PasteFromWord','-','Undo','Redo' ] },
			{ name: 'links', items : [ 'Link','Unlink','Anchor' ] },
			{ name: 'basicstyles', items : [ 'Bold','Italic','Underline','Strike','Subscript','Superscript','-','NumberedList','BulletedList' ] },
			{ name: 'insert', items : [ 'Image','Table','HorizontalRule','SpecialChar','TextColor' ] },
			{ name: 'paragraph', items : ['RemoveFormat','-','Outdent','Indent','-','JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock' ] },
			{ name: 'styles', items : [ 'Styles','Format','Font','FontSize' ] }
		]
    });	

//]]>	
</script> 

<!---------------------Puntke und Speichern-------------------->
<br />

	<label for="Punkte">Punkte:</label>
	<input type="input" name="Punkte" value="<?php echo $fragen['Punkte'];?>" disabled/><br />
<?php
	$js = 'onClick="setanswer()"';
	echo form_submit('Submit','Antwort Speichern',$js); 
?>
</form>

<!-------- Navigation Klausur--------------->
<div style="font-size:large;">
<?php for($i = 1; $i < $pages+1; $i++): ?>
<?php 
    $j = $i+1;
	$atts = array('class' => 'link-class',
		  		  'OnClick' => "setanswer()");
    echo anchor('klausurenfragen_controller/classtest_view/'.$i, ''.$i, $atts);

?> &nbsp;
<?php endfor ?>
</div>
<br />
<br />
<br />


<!-------- Abgabe Klausur--------------->
<?php echo validation_errors(); ?>
<?php echo form_open('klausurenfragen_controller/finishclasstest',array('name' => 'Abgabe')) ?>
	<input class="art-button" type="submit" name="submit" value="Abgeben" />
</form>
<h2 id="countdown"></h2>
<script>
countdown('countdown', <?php echo date("H"); ?>, <?php echo date("i"); ?>, <?php echo date("s"); ?>);
function countdown(element,hours, minutes, seconds) {
    // set time for the particular countdown
    var starthour = <?php echo $classtesttime['Starthour']*60*60 ?>;
    var startminute = <?php echo $classtesttime['Startminute']*60 ?>;
    var startsecond = <?php echo $classtesttime['Startsecond'] ?>;
    var start = starthour + startminute + startsecond;
    var now = hours*60*60 + minutes*60 + seconds;
    var dauer = <?php echo $classtesttime['Duration'] ?>;
    var time =  dauer*60 -(now - start);
    //var time = minutes*60 + seconds;
    var interval = setInterval(function() {
        var el = document.getElementById(element);
        // if the time is 0 then end the counter
       	if(time <= 0) {
			var abgabeurl = "index.php/klausurenfragen_controller/finishclasstest";
			window.location.href = abgabeurl;
       	}
        var minutes = Math.floor( time / 60 );
        if (minutes < 10) minutes = "0" + minutes;
        	var seconds = time % 60;
        if (seconds < 10) seconds = "0" + seconds; 
       		var text = minutes + ':' + seconds;
        el.innerHTML = text;
        time--;
    }, 1000);
}
</script>
